<?php

namespace App\Models\Traits;


trait QueryTrait
{
    public function scopeRecent($query)
    {
        return $query->orderBy('id', 'desc');
    }

    public function scopeOrdered($query)
    {
        return $query->orderBy('order', 'desc');
    }

    public function scopeName($query, $name)
    {
        return $query->where('name', 'like', '%' . $name . '%');
    }

    public function scopeActive($query)
    {
        return $query->where('active', 1);
    }

    public function scopeType($query, $type)
    {
        return $query->where('type', $type);
    }
}